<template>
  <div class="vir-from-page">
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="活动名称活动名称活动名称活动名称">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="活动区域">
        <el-select v-model="form.region" placeholder="请选择活动区域">
          <el-option label="区域一" value="shanghai"></el-option>
          <el-option label="区域二" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="活动时间">
        <el-row>
          <el-col :span="11">
            <el-date-picker type="date" placeholder="选择日期" v-model="form.date1" style="width: 100%;"></el-date-picker>
          </el-col>
          <el-col class="vir-form-line" :span="2">-</el-col>
          <el-col :span="11">
            <el-time-picker type="fixed-time" placeholder="选择时间" v-model="form.date2" style="width: 100%;"></el-time-picker>
          </el-col>
        </el-row>
      </el-form-item>
      <el-form-item label="即时配送">
        <el-switch v-model="form.delivery"></el-switch>
      </el-form-item>
      <el-form-item label="活动性质">
        <el-checkbox-group v-model="form.type" class="vir-form-checkbox">
          <el-checkbox label="美食/餐厅线上活动" name="type"></el-checkbox>
          <el-checkbox label="地推活动" name="type"></el-checkbox>
          <el-checkbox label="线下主题活动" name="type"></el-checkbox>
          <el-checkbox label="单纯品牌曝光" name="type"></el-checkbox>
        </el-checkbox-group>
      </el-form-item>
      <el-form-item label="特殊资源">
        <el-radio-group v-model="form.resource" class="vir-form-radio">
          <el-radio label="线上品牌商赞助"></el-radio>
          <el-radio label="线下场地免费"></el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="特殊资源">
        <el-slider v-model="form.slider"></el-slider>
      </el-form-item>
      <el-form-item label="特殊资源">
        <el-input-number v-model="form.number" :min="1" :max="10" label="描述文字"></el-input-number>
      </el-form-item>
      <el-form-item label="特殊资源">
        <el-cascader :options="options" v-model="form.option">
        </el-cascader>
      </el-form-item>
      <el-form-item label="活动形式">
        <el-date-picker v-model="form.date" type="date" placeholder="选择日期"></el-date-picker>
      </el-form-item>
      <el-form-item label="活动形式">
        <el-time-select v-model="form.time" :picker-options="{start: '08:30', step: '00:15', end: '18:30'}" placeholder="选择时间"></el-time-select>
      </el-form-item>
      <el-form-item label="活动形式">
        <el-input type="textarea" v-model="form.desc"></el-input>
      </el-form-item>
      <el-form-item label="活动形式">
        <vir-editor class="vir-editor-0" v-model="form.desc"></vir-editor>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { VirEditor } from '@/components/editor';

@Component({ components: { VirEditor } })
export default class TestPage extends Vue {
  private form: any = {
    name: '',
    region: '',
    date1: '',
    date2: '',
    delivery: false,
    type: [],
    resource: '',
    desc: '',
    slider: 50,
    number: 5,
    option: [],
    date: '',
    time: ''
  };
  private options: any[] = [{
    value: 'zhinan',
    label: '指南',
    children: [{
      value: 'shejiyuanze',
      label: '设计原则',
      children: [{
        value: 'yizhi',
        label: '一致设计原则设计原则设计原则'
      }, {
        value: 'fankui',
        label: '反馈'
      }, {
        value: 'xiaolv',
        label: '效率'
      }, {
        value: 'kekong',
        label: '可控'
      }]
    }]
  }];

  private onSubmit() {
    console.log('submit!', this.form);
  }
}
</script>
<style lang="scss" scoped>
.vir-from-page {
  .vir-form-line {
    text-align: center;
  }
  .vir-form-checkbox {
    width: 100%;
    & > * {
      width: 50%;
      float: left;
      padding-right: 20px;
      margin: 0;
      padding: 0;
    }
  }
  .vir-form-radio {
    @extend .vir-form-checkbox;
  }
}
</style>
